import { shopDoorsList, deleteShopDoor, updateShopDoor, addShopDoor,updateShopDoorCommodity } from '@/api/shopDoor'
export default {
    namespaced: true,
    state: {
        shopDoorstate: []
    },
    getters: {
        shopDoorgetter(state) {
            return state.shopDoorstate
        }
    },
    mutations: {
        //渲染已经审核过的门店
        shopDoorMtt(state, payload) {

            let result = payload.filter((item) => {
                return item.isFlag === 1
            });
            state.shopDoorstate = result
        },

        deleteShopDoorMtt(state, payload) {
            state.shopDoorstate = payload
        },

        updateShopDoorMtt(state, payload) {
            state.shopDoorstate = payload
        },

        addShopDoorMtt(state, payload) {
            state.shopDoorstate = payload
        },
        updateShopDoorCommodityMtt(state, payload) {
            state.shopDoorstate = payload
        },
    },
    actions: {
        shopDoorAction(context) {
            shopDoorsList().then((res) => {
                context.commit("shopDoorMtt", res.rows)
            })
        },
        //删除
        deleteShopDoorAction(context, deleteId) {
            deleteShopDoor(deleteId)
        },
        //修改
        updateShopDoorAction(context, updateForm) {
            updateShopDoor(updateForm)
        },
        //增加
        addShopDoorAction(context, addForm) {
            addShopDoor(addForm)
        },
        updateShopDoorCommodityAction(context, payload) {
          
            updateShopDoorCommodity(payload)
        },
    }
}